package com.eric.service.impl;

import com.eric.dao.Roles_PermissionDao;
import com.eric.dao.UserDao;
import com.eric.dao.User_RolesDao;
import com.eric.entity.Roles_Permission;
import com.eric.entity.User;
import com.eric.entity.User_Roles;
import com.eric.service.GetUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GetUserInfoServiceImpl implements GetUserInfoService {

    @Autowired
    private UserDao userInfoDao;
    @Autowired
    private User_RolesDao userRolesDao;
    @Autowired
    private Roles_PermissionDao rolesPermissionDao;
    @Override
    public List<User> getAllUserInfo() {

        return userInfoDao.getAllUserInfo();
    }

    @Override
    public User getOneById(Integer id) {
        return userInfoDao.getOneById(id);
    }

    @Override
    public User getONeByNameService(String loginName) {

        return userInfoDao.getAllByUserName(loginName);
    }

//    获取角色的权限表
    @Override
    public List<Roles_Permission> getByRole_id(Integer role_id) {
        return rolesPermissionDao.getByRole_id(role_id);
    }

//    通过登录用户对象获取到对应角色表
    @Override
    public List<User_Roles> getRolesList(User user) {

        return userRolesDao.getRolesList(user.getId());
    }

//    通过User对象的id获取User_Roles对象集合
    @Override
    public List<User_Roles> getRolesListByUserId(Integer user_id) {
        return  userRolesDao.getRolesList(user_id);
    }
}
